﻿using Excel4DB.Util.Interfaces;
using Excel4DBModel;
using System;

namespace Excel4DB.Util
{
    public class DataBaseFactory
    {
        private static object objLock = new object();
        private DataBaseFactory() { }
        public static DataBaseFactory Instance { get; } = new DataBaseFactory();

        public IDataBase Create()
        {
            string dbType= ConfigHelper.Instance.DbType;
            if (string.IsNullOrWhiteSpace(dbType))
                return null;
            bool b= Enum.TryParse(dbType, out DataBaseType dataBaseType);
            if (!b)
                return null;
            switch (dataBaseType)
            {
                case DataBaseType.SqlServer:
                    return new SqlDataBase();
                case DataBaseType.MySql:
                    return new SqlDataBase();
                default:
                    return null;
            }
        }
    }
}
